/**
 * @author Administrator
 */
$(function(){
    $("#reserveformID").validationEngine({
        validationEventTriggers : "keyup blur",
        openDebug : true
    });
    
    $("#start").timepicker({
        dateFormat : 'yy-mm-dd',
        timeFormat : 'hh:mm',
        hourMin : 8,
        hourMax : 17,
        hourGrid : 3,
        minuteGrid : 15,
        timeText : '时间',
        hourText : '时',
        minuteText : '分',
        timeOnlyTitle : '选择时间',
        onClose : function(dateText, inst) {
            if ($('#start').val() != '') {
                var testStartDate = $('#start').datetimepicker('getDate');
                var testEndDate = $('#end').datetimepicker('getDate');
                if (testStartDate > testEndDate) $('#end').datetimepicker('setDate', testStartDate);
            }
            else {
                $('#end').val(dateText);
            }
        },
        onSelect : function(selectedDateTime) {
            $('#end').datetimepicker('option', 'minDate', $('#end').datetimepicker('getDate'));
        }
    });
    $("#end").timepicker({
        dateFormat : 'yy-mm-dd',
        timeFormat : 'hh:mm',
        hourMin : 8,
        hourMax : 17,
        hourGrid : 3,
        minuteGrid : 15,
        timeText : '时间',
        hourText : '时',
        minuteText : '分',
        onClose : function(dateText, inst) {
            if ($('#start').val() != '') {
                var testStartDate = $('#start').datetimepicker('getDate');
                var testEndDate = $("#end").datetimepicker('getDate');
                if (testStartDate > testEndDate) $('#start').datetimepicker('setDate', testEndDate);
            }
            else {
                $('#start').val(dateText);
            }
        },
        onSelect : function(selectedDateTime) {
            $('#start').timepicker('option', 'maxDate', $("#end").timepicker('getDate'));
        }
    });
    $("#repweeks").change(function(){
        if($(this).val()=="0"){
            $("#weeksdiv").hide("slow"); 
        }
        else{
            $("#weeksdiv").show("slow"); 
        }
    });
    $("#addhelper").hide();
    $(".selectpicker").selectpicker();
    $("#weeks").buttonset();
});